﻿Public Module ModuleMath

    Public Function IsLeap(ByVal year As Integer) As Boolean
        If (year Mod 400 = 0 AndAlso year Mod 3200 <> 0) OrElse (year Mod 4 = 0 AndAlso year Mod 100 <> 0) OrElse (year Mod 3200 = 0 AndAlso year Mod 172800 = 0) Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Function Coin() As Boolean    
        Dim rnd As New Random()
        Return rnd.Next(0, 2)
    End Function

    ''' <summary>
    ''' [from, to)
    ''' </summary>
    ''' <param name="from"></param>
    ''' <param name="to"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GenerateRandom(ByVal [from] As Double, ByVal [to] As Double) As Double
        Static rm As New StaticInitializer(Sub() Randomize())
        Dim rnd As New Random()
        Return rnd.Next([from], [to])
    End Function

End Module